package com.zhangyang.dubbo.user;

import com.zhangyang.dubbo.IUserService;
import com.zhangyang.dubbo.UserLoginRequest;
import com.zhangyang.dubbo.UserLoginResponse;
import com.zhangyang.dubbo.dal.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by ASUS on 2017/9/4.
 */
@Service(value = "userService")
public class UserServiceImpl implements IUserService {

    @Autowired
    UserDao userDao;

    /**
     * 处理登录业务
     * @param userLoginRequest
     * @return
     */
    public UserLoginResponse doLogin(UserLoginRequest userLoginRequest){
        if(userLoginRequest.getUserName()!=null &&
                userLoginRequest.getUserName().equals("root")){
            return  new UserLoginResponse("登录成功",200);
        }
        return  new UserLoginResponse("登录失败",400);
    }

    /**
     * 进行扣钱
     * @param money
     */
    public void debet(int money,String userName,int id) {
        userDao.debet(money,userName,id);
        System.out.println("进行执行 扣钱的操作! money:"+money+"...userName:"+userName+"..id:"+id);
    }
}
